package flc.ast.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class IndicatorAdapter extends StkProviderMultiAdapter<Integer> {

    public IndicatorAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(40));
        addItemProvider(new IndicatorProvider());
    }

    private int selPosition;

    public void setSelPosition(int selPosition) {
        this.selPosition = selPosition;
    }

    private class IndicatorProvider extends BaseItemProvider<Integer> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_indicator;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, Integer bean) {
            if (baseViewHolder.getBindingAdapterPosition()==selPosition) {
                baseViewHolder.setImageResource(R.id.ivIndicatorItemImg, R.drawable.shape_indic_sel);
            } else {
                baseViewHolder.setImageResource(R.id.ivIndicatorItemImg, R.drawable.shape_indic_not_sel);
            }
        }
    }
}
